package com.example.ll_video.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.example.ll_video.R;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;

import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;

public abstract class BaseActivity extends FragmentActivity implements View.OnClickListener {
    TextView rightText1;
    TextView rightText2;
    private LinearLayout llbase;
    private TextView titleTv;
    private ImageView backImage;
    private View contentView;
    private String titleStr;
    private RelativeLayout rlTitle;
    public Context context;

    public void setTitle(String titleStr) {
        this.titleStr = titleStr;
        if (titleTv != null) {
            titleTv.setText(titleStr);
        }
    }
    public void setRightText1(String text1,View.OnClickListener clickListener){
        rightText1.setVisibility(View.VISIBLE);
        rightText1.setText(text1);
        rightText1.setOnClickListener(clickListener);
    }

    public void showBackImage(View.OnClickListener onClickListener){
        backImage.setVisibility(View.VISIBLE);
        backImage.setOnClickListener(onClickListener);
    }
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.base_activity_math);
        QMUIStatusBarHelper.isFullScreen(this);
        context = this;
        titleTv =findViewById(R.id.title_text);
        backImage = findViewById(R.id.back_image);
        rightText1 = this.findViewById(R.id.right_text);
        rightText2 = this.findViewById(R.id.right2_text);
        llbase = this.findViewById(R.id.ll_main);
        rlTitle = this.findViewById(R.id.rl_title);
        onCreate();

    }

    public void hintTilteLayout(){
        rlTitle.setVisibility(View.GONE);
    }
    protected void contentView(int layoutId) {
        contentView = getLayoutInflater().inflate(layoutId, null);
        if (contentView != null) {
            llbase.addView(contentView);
        }
    }

    public abstract void onCreate();

    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back_image://返回键
                finish();
                break;
            default://其他
                break;
        }
    }
}
